<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Dynamic loading</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Dynamic_loading"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Dynamic_loading rootpage-Dynamic_loading skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Dynamic loading</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Not to be confused with <a href="Active_load" title="Active load">dynamic load</a>.</div>
<div role="note" class="hatnote navigation-not-searchable">"Dynamically loaded library" redirects here. Not to be confused with <a href="Dynamic-link_library" title="Dynamic-link library">dynamically linked library</a>.</div>
<p>
<b>Dynamic loading</b> is a mechanism by which a <a href="Computer_program" title="Computer program">computer program</a> can, at <a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run time</a>, load a <a href="Library_(computing)" title="Library (computing)">library</a> (or other <a href="Executable_file" class="mw-redirect" title="Executable file">binary</a>) into memory, retrieve the addresses of functions and variables contained in the library, execute those <a href="Library_function" class="mw-redirect" title="Library function">functions</a> or access those variables, and unload the library from memory. It is one of the three mechanisms by which a computer program can use some other software within the program; the others are <a href="Static_linking" class="mw-redirect" title="Static linking">static linking</a> and <a href="Dynamic_linking" class="mw-redirect" title="Dynamic linking">dynamic linking</a>. Unlike static linking and dynamic linking, dynamic loading allows a <a href="Computer_program" title="Computer program">computer program</a> to start up in the absence of these libraries, to discover available libraries, and to potentially gain additional functionality.<sup id="cite_ref-autobook_1-0" class="reference"><a href="#cite_note-autobook-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Elf_Dynamic_Loading_2-0" class="reference"><a href="#cite_note-Elf_Dynamic_Loading-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>Dynamic loading was a common technique for IBM's <a href="Operating_systems" class="mw-redirect" title="Operating systems">operating systems</a> for <a href="System/360" class="mw-redirect" title="System/360">System/360</a> such as <a href="OS/360" class="mw-redirect" title="OS/360">OS/360</a>, particularly for <a href="I/O" class="mw-redirect" title="I/O">I/O</a> <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutines</a>, and for <a href="COBOL" title="COBOL">COBOL</a> and <a href="PL/I" title="PL/I">PL/I</a> <a href="Runtime_library" title="Runtime library">runtime libraries</a>, and continues to be used in IBM's operating systems for <a href="Z/Architecture" title="Z/Architecture">z/Architecture</a>, such as <a href="Z/OS" title="Z/OS">z/OS</a>. As far as the application programmer is concerned, the loading is largely transparent, since it is mostly handled by the operating system (or its I/O subsystem). The main advantages are:
</p>
<ul><li>Fixes (<a href="Patch_(computing)" title="Patch (computing)">patches</a>) to the subsystems fixed all programs at once, without the need to relink them</li>
<li>Libraries could be protected from unauthorized modification</li></ul>
<p><a href="IBM" title="IBM">IBM</a>'s strategic <a href="Transaction_processing" title="Transaction processing">transaction processing</a> system, <a href="CICS" title="CICS">CICS</a> (1970s onwards) uses dynamic loading extensively both for its <a href="Kernel_(operating_system)" title="Kernel (operating system)">kernel</a> and for normal <a href="Application_program" class="mw-redirect" title="Application program">application program</a> loading. Corrections to application programs could be made offline and new copies of changed programs loaded dynamically without needing to restart CICS<sup id="cite_ref-CICS_3-0" class="reference"><a href="#cite_note-CICS-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-CEMT_4-0" class="reference"><a href="#cite_note-CEMT-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> (which can, and frequently does, run <a href="24/7" class="mw-redirect" title="24/7">24/7</a>).
</p><p><a href="Shared_libraries" class="mw-redirect" title="Shared libraries">Shared libraries</a> were added to Unix in the 1980s, but initially without the ability to let a program load additional libraries after startup.<sup id="cite_ref-spe_5-0" class="reference"><a href="#cite_note-spe-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Uses">Uses</h2></div>
<p>Dynamic loading is most frequently used in implementing <a href="Plug-in_(computing)" title="Plug-in (computing)">software plugins</a>.<sup id="cite_ref-autobook_1-1" class="reference"><a href="#cite_note-autobook-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> For example, the <a href="Apache_Web_Server" class="mw-redirect" title="Apache Web Server">Apache Web Server's</a> <code>*.dso</code> "dynamic shared object" plugin files are <a href="Library_(computing)" title="Library (computing)">libraries</a> which are loaded at runtime with dynamic loading.<sup id="cite_ref-apache_6-0" class="reference"><a href="#cite_note-apache-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> Dynamic loading is also used in implementing <a href="Computer_programs" class="mw-redirect" title="Computer programs">computer programs</a> where multiple different libraries may supply the requisite functionality and where the user has the option to select which library or libraries to provide.
</p>
<div class="mw-heading mw-heading2"><h2 id="In_C/C++">In C/C++</h2></div>
<p>Not all systems support dynamic loading. <a href="Unix-like" title="Unix-like">Unix-like</a> operating systems such as <a href="MacOS" title="MacOS">macOS</a>, <a href="Linux" title="Linux">Linux</a>, and <a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a> provide dynamic loading with the <a href="C_(programming_language)" title="C (programming language)">C programming language</a> "dl" library. The <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> <a href="Operating_system" title="Operating system">operating system</a> provides dynamic loading through the <a href="Windows_API" title="Windows API">Windows API</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Summary">Summary</h3></div>
<table class="wikitable">
<tbody><tr>
<th>Name
</th>
<th><a href="Unix" title="Unix">Standard POSIX/Unix API</a>
</th>
<th><a href="Windows_API" title="Windows API">Microsoft Windows API</a>
</th></tr>
<tr>
<td>Header file inclusion
</td>
<td><code>#include <dlfcn.h></code>
</td>
<td><code>#include <windows.h></code>
</td></tr>
<tr>
<td>Definitions for header
</td>
<td><code>dl</code>
<p>(<code>libdl.so</code>, <code>libdl.dylib</code>, etc. depending on the <a href="Operating_system" title="Operating system">OS</a>)
</p>
</td>
<td><code>kernel32.dll</code>
</td></tr>
<tr>
<td>Loading the library
</td>
<td><code>dlopen</code>
</td>
<td><code>LoadLibrary</code><br><code>LoadLibraryEx</code><br>
</td></tr>
<tr>
<td>Extracting contents
</td>
<td><code>dlsym</code>
</td>
<td><code>GetProcAddress</code>
</td></tr>
<tr>
<td>Unloading the library
</td>
<td><code>dlclose</code>
</td>
<td><code>FreeLibrary</code>
</td></tr></tbody></table>
<div class="mw-heading mw-heading3"><h3 id="Loading_the_library">Loading the library</h3></div>
<p>Loading the library is accomplished with <code>LoadLibrary</code> or <code>LoadLibraryEx</code> on <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> and with <code>dlopen</code> on <a href="Unix-like" title="Unix-like">Unix-like</a> <a href="Operating_system" title="Operating system">operating systems</a>. Examples follow:
</p>
<div class="mw-heading mw-heading4"><h4 id="Most_Unix-like_operating_systems_(Solaris,_Linux,_*BSD,_etc.)">Most Unix-like operating systems (Solaris, Linux, *BSD, etc.)</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">sdl_library</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dlopen</span><span class="p">(</span><span class="s">"libSDL.so"</span><span class="p">,</span><span class="w"> </span><span class="n">RTLD_LAZY</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_library</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// use the result in a call to dlsym</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="macOS">macOS</h4></div>
<p>As a <a href="Unix" title="Unix">Unix</a> library:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">sdl_library</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dlopen</span><span class="p">(</span><span class="s">"libSDL.dylib"</span><span class="p">,</span><span class="w"> </span><span class="n">RTLD_LAZY</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_library</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// use the result in a call to dlsym</span>
<span class="p">}</span>
</pre></div>
<p>As a <a href="Application_framework" title="Application framework">macOS Framework</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">sdl_library</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dlopen</span><span class="p">(</span><span class="s">"/Library/Frameworks/SDL.framework/SDL"</span><span class="p">,</span><span class="w"> </span><span class="n">RTLD_LAZY</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_library</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// use the result in a call to dlsym</span>
<span class="p">}</span>
</pre></div>
<p>Or if the framework or bundle contains Objective-C code:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="bp">NSBundle</span><span class="w"> </span><span class="o">*</span><span class="n">bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="bp">NSBundle</span><span class="w"> </span><span class="n">bundleWithPath</span><span class="o">:</span><span class="s">@"/Library/Plugins/Plugin.bundle"</span><span class="p">];</span>
<span class="bp">NSError</span><span class="w"> </span><span class="o">*</span><span class="n">err</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">nil</span><span class="p">;</span>
<span class="k">if</span><span class="w"> </span><span class="p">([</span><span class="n">bundle</span><span class="w"> </span><span class="n">loadAndReturnError</span><span class="o">:&</span><span class="n">err</span><span class="p">])</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// Use the classes and functions in the bundle.</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// Handle error.</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Windows">Windows</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">HMODULE</span><span class="w"> </span><span class="n">sdl_library</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">LoadLibrary</span><span class="p">(</span><span class="n">TEXT</span><span class="p">(</span><span class="s">"SDL.dll"</span><span class="p">));</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_library</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// use the result in a call to GetProcAddress</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Extracting_library_contents">Extracting library contents</h3></div>
<p>Extracting the contents of a dynamically loaded library is achieved with <code>GetProcAddress</code> on <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> and with <code>dlsym</code> on <a href="Unix" title="Unix">Unix</a>-like <a href="Operating_system" title="Operating system">operating systems</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Unix-like_operating_systems_(Solaris,_Linux,_*BSD,_macOS,_etc.)">Unix-like operating systems (Solaris, Linux, *BSD, macOS, etc.)</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">initializer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dlsym</span><span class="p">(</span><span class="n">sdl_library</span><span class="p">,</span><span class="w"> </span><span class="s">"SDL_Init"</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">initializer</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// cast initializer to its proper type and use</span>
<span class="p">}</span>
</pre></div>
<p>On macOS, when using Objective-C bundles, one can also:
</p>
<div class="mw-highlight mw-highlight-lang-objc mw-content-ltr" dir="ltr"><pre><span class="kt">Class</span><span class="w"> </span><span class="n">rootClass</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">bundle</span><span class="w"> </span><span class="n">principalClass</span><span class="p">];</span><span class="w"> </span><span class="c1">// Alternatively, NSClassFromString() can be used to obtain a class by name.</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">rootClass</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">id</span><span class="w"> </span><span class="n">object</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[[</span><span class="n">rootClass</span><span class="w"> </span><span class="n">alloc</span><span class="p">]</span><span class="w"> </span><span class="n">init</span><span class="p">];</span><span class="w"> </span><span class="c1">// Use the object.</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// Report error.</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Windows_2">Windows</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">FARPROC</span><span class="w"> </span><span class="n">initializer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">GetProcAddress</span><span class="p">(</span><span class="n">sdl_library</span><span class="p">,</span><span class="s">"SDL_Init"</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">initializer</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// report error ...</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// cast initializer to its proper type and use</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Converting_a_library_function_pointer">Converting a library function pointer</h3></div>
<p>The result of <code>dlsym()</code> or <code>GetProcAddress()</code> has to be converted to a pointer of the appropriate type before it can be used.
</p>
<div class="mw-heading mw-heading4"><h4 id="Windows_3">Windows</h4></div>
<p>In Windows, the conversion is straightforward, since FARPROC is essentially already a <a href="Function_pointer" title="Function pointer">function pointer</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">typedef</span><span class="w"> </span><span class="n">INT_PTR</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">FARPROC</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
<p>This can be problematic when the address of an object is to be retrieved rather than a function. However, usually one wants to extract functions anyway, so this is normally not a problem.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">typedef</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">sdl_init_function_type</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span>
<span class="n">sdl_init_function_type</span><span class="w"> </span><span class="n">init_func</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_init_function_type</span><span class="p">)</span><span class="w"> </span><span class="n">initializer</span><span class="p">;</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Unix_(POSIX)">Unix (POSIX)</h4></div>
<p>According to the POSIX specification, the result of <code>dlsym()</code> is a <code>void</code> pointer. However, a function pointer is not required to even have the same size as a data object pointer, and therefore a valid conversion between type <code>void*</code> and a pointer to a function may not be easy to implement on all platforms.
</p><p>On most systems in use today, function and object pointers are <i>de facto</i> convertible. The following code snippet demonstrates one workaround which allows to perform the conversion anyway on many systems:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">typedef</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">sdl_init_function_type</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span>
<span class="n">sdl_init_function_type</span><span class="w"> </span><span class="n">init_func</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">sdl_init_function_type</span><span class="p">)</span><span class="n">initializer</span><span class="p">;</span>
</pre></div>
<p>The above snippet will give a warning on some compilers: <code>warning: dereferencing type-punned pointer will break strict-aliasing rules</code>. Another workaround is:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">typedef</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">sdl_init_function_type</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span>
<span class="k">union</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">sdl_init_function_type</span><span class="w"> </span><span class="n">func</span><span class="p">;</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">obj</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="n">alias</span><span class="p">;</span>
<span class="n">alias</span><span class="p">.</span><span class="n">obj</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">initializer</span><span class="p">;</span>
<span class="n">sdl_init_function_type</span><span class="w"> </span><span class="n">init_func</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">alias</span><span class="p">.</span><span class="n">func</span><span class="p">;</span>
</pre></div>
<p>which disables the warning even if strict aliasing is in effect. This makes use of the fact that reading from a different union member than the one most recently written to (called "<a href="Type_punning" title="Type punning">type punning</a>") is common, and explicitly allowed even if strict aliasing is in force, provided the memory is accessed through the union type directly.<sup id="cite_ref-gcc-strict-aliasing_7-0" class="reference"><a href="#cite_note-gcc-strict-aliasing-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> However, this is not strictly the case here, since the function pointer is copied to be used outside the union. Note that this trick may not work on platforms where the size of data pointers and the size of function pointers is not the same.
</p>
<div class="mw-heading mw-heading4"><h4 id="Solving_the_function_pointer_problem_on_POSIX_systems">Solving the function pointer problem on POSIX systems</h4></div>
<p>The fact remains that any conversion between function and data object pointers has to be regarded as an (inherently non-portable) implementation extension, and that no "correct" way for a direct conversion exists, since in this regard the POSIX and ISO standards contradict each other.
</p><p>Because of this problem, the POSIX documentation on <code>dlsym()</code> for the outdated issue 6 stated that "a future version may either add a new function to return function pointers, or the current interface may be deprecated in favor of two new functions: one that returns data pointers and the other that returns function pointers".<sup id="cite_ref-POSIX_dlopen_8-0" class="reference"><a href="#cite_note-POSIX_dlopen-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p><p>For the subsequent version of the standard (issue 7, 2008), the problem has been discussed and the conclusion was that function pointers have to be convertible to <code>void*</code> for POSIX compliance.<sup id="cite_ref-POSIX_dlopen_8-1" class="reference"><a href="#cite_note-POSIX_dlopen-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> This requires compiler makers to implement a working cast for this case.
</p><p>If the contents of the library can be changed (i.e. in the case of a custom library), in addition to the function itself a pointer to it can be exported. Since a pointer to a function pointer is itself an object pointer, this pointer can always be legally retrieved by call to <code>dlsym()</code> and subsequent conversion. However, this approach requires maintaining separate pointers to all functions that are to be used externally, and the benefits are usually small.
</p>
<div class="mw-heading mw-heading3"><h3 id="Unloading_the_library">Unloading the library</h3></div>
<p>Loading a library causes memory to be allocated; the library must be deallocated in order to avoid a <a href="Memory_leak" title="Memory leak">memory leak</a>. Additionally, failure to unload a library can prevent <a href="Filesystem" class="mw-redirect" title="Filesystem">filesystem</a> operations on the <a href="Computer_file" title="Computer file">file</a> which contains the library. Unloading the library is accomplished with <code>FreeLibrary</code> on <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> and with <code>dlclose</code> on Unix-like <a href="Operating_system" title="Operating system">operating systems</a>. However, unloading a DLL can lead to program crashes if objects in the main application refer to memory allocated within the DLL. For example, if a DLL introduces a new class and the DLL is closed, further operations on instances of that class from the main application will likely cause a memory access violation. Likewise, if the DLL introduces a factory function for instantiating dynamically loaded classes, calling or dereferencing that function after the DLL is closed leads to undefined behaviour.
</p>
<div class="mw-heading mw-heading4"><h4 id="Unix-like_operating_systems_(Solaris,_Linux,_*BSD,_macOS,_etc.)_2">Unix-like operating systems (Solaris, Linux, *BSD, macOS, etc.)</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">dlclose</span><span class="p">(</span><span class="n">sdl_library</span><span class="p">);</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Windows_4">Windows</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">FreeLibrary</span><span class="p">(</span><span class="n">sdl_library</span><span class="p">);</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Special_library">Special library</h3></div>
<p>The implementations of dynamic loading on <a href="Unix-like" title="Unix-like">Unix-like</a> operating systems and <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> allow programmers to extract symbols from the currently executing process.
</p><p>Unix-like operating systems allow programmers to access the global symbol table, which includes both the main executable and subsequently loaded dynamic libraries.
</p><p><a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> allows programmers to access symbols exported by the main executable. Windows does not use a global symbol table and has no API to search across multiple modules to find a symbol by name.
</p>
<div class="mw-heading mw-heading4"><h4 id="Unix-like_operating_systems_(Solaris,_Linux,_*BSD,_macOS,_etc.)_3">Unix-like operating systems (Solaris, Linux, *BSD, macOS, etc.)</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">this_process</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dlopen</span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span><span class="mi">0</span><span class="p">);</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Windows_5">Windows</h4></div>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">HMODULE</span><span class="w"> </span><span class="n">this_process</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">GetModuleHandle</span><span class="p">(</span><span class="nb">NULL</span><span class="p">);</span>
<span class="n">HMODULE</span><span class="w"> </span><span class="n">this_process_again</span><span class="p">;</span>
<span class="n">GetModuleHandleEx</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="o">&</span><span class="n">this_process_again</span><span class="p">);</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="In_Java">In Java</h2></div>
<div role="note" class="hatnote navigation-not-searchable">Further information: <a href="Java_class_loader" title="Java class loader">Java class loader</a></div>
<p>In the <a href="Java_programming_language" class="mw-redirect" title="Java programming language">Java programming language</a>, <a href="Java_class" class="mw-redirect" title="Java class">classes</a> can be dynamically loaded using the <b><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/ClassLoader.html">ClassLoader</a></code></b> object. For example:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">Class</span><span class="w"> </span><span class="n">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ClassLoader</span><span class="p">.</span><span class="na">getSystemClassLoader</span><span class="p">().</span><span class="na">loadClass</span><span class="p">(</span><span class="n">name</span><span class="p">);</span>
<span class="n">Object</span><span class="w"> </span><span class="n">obj</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">type</span><span class="p">.</span><span class="na">newInstance</span><span class="p">();</span>
</pre></div>
<p>The Reflection mechanism also provides a means to load a class if it isn't already loaded. It uses the classloader of the current class:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">Class</span><span class="w"> </span><span class="n">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Class</span><span class="p">.</span><span class="na">forName</span><span class="p">(</span><span class="n">name</span><span class="p">);</span>
<span class="n">Object</span><span class="w"> </span><span class="n">obj</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">type</span><span class="p">.</span><span class="na">newInstance</span><span class="p">();</span>
</pre></div>
<p>However, there is no simple way to unload a class in a controlled way. Loaded classes can only be unloaded in a controlled way, i.e. when the programmer wants this to happen, if the classloader used to load the class is not the system class loader, and is itself unloaded. When doing so, various details need to be observed to ensure the class is really unloaded. This makes unloading of classes tedious.
</p><p>Implicit unloading of classes, i.e. in an uncontrolled way by the garbage collector, has changed a few times in Java. Until Java 1.2. the garbage collector could unload a class whenever it felt it needed the space, independent of which class loader was used to load the class. Starting with Java 1.2 classes loaded via the system classloader were never unloaded and classes loaded via other classloaders only when this other classloader was unloaded. Starting with Java 6 classes can contain an internal marker indicating to the garbage collector they can be unloaded if the garbage collector desires to do so, independent of the classloader used to load the class. The garbage collector is free to ignore this hint.
</p><p>Similarly, libraries implementing native methods are dynamically loaded using the <code>System.loadLibrary</code> method. There is no <code>System.unloadLibrary</code> method.
</p>
<div class="mw-heading mw-heading2"><h2 id="Platforms_without_dynamic_loading">Platforms without dynamic loading</h2></div>
<p>Despite its promulgation in the 1980s through Unix and Windows, some systems still chose not to add—or even to remove—dynamic loading. For example, <a href="Plan_9_from_Bell_Labs" title="Plan 9 from Bell Labs">Plan 9 from Bell Labs</a> and its successor 9front intentionally avoid dynamic linking, as they consider it to be "harmful".<sup id="cite_ref-Cat-V_9-0" class="reference"><a href="#cite_note-Cat-V-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> The <a href="Go_(programming_language)" title="Go (programming language)">Go programming language</a>, by some of the same developers as Plan 9, also did not support dynamic linking, but plugin loading is available since <a rel="nofollow" class="external text" href="https://tip.golang.org/doc/go1.8">Go 1.8</a> (February 2017). The Go runtime and any library functions are statically linked into the compiled binary.<sup id="cite_ref-Golang_10-0" class="reference"><a href="#cite_note-Golang-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1266661725">
/* start https://en.wikipedia.org/ */
.mw-parser-output .portalbox{padding:0;margin:0.5em 0;display:table;box-sizing:border-box;max-width:175px;list-style:none}.mw-parser-output .portalborder{border:1px solid var(--border-color-base,#a2a9b1);padding:0.1em;background:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output .portalbox-entry{display:table-row;font-size:85%;line-height:110%;height:1.9em;font-style:italic;font-weight:bold}.mw-parser-output .portalbox-image{display:table-cell;padding:0.2em;vertical-align:middle;text-align:center}.mw-parser-output .portalbox-link{display:table-cell;padding:0.2em 0.2em 0.2em 0.3em;vertical-align:middle}@media(min-width:720px){.mw-parser-output .portalleft{margin:0.5em 1em 0.5em 0}.mw-parser-output .portalright{clear:right;float:right;margin:0.5em 0 0.5em 1em}}
/* end https://en.wikipedia.org/ */
</style>
<style data-mw-deduplicate="TemplateStyles:r1184024115">
/* start https://en.wikipedia.org/ */
.mw-parser-output .div-col{margin-top:0.3em;column-width:30em}.mw-parser-output .div-col-small{font-size:90%}.mw-parser-output .div-col-rules{column-rule:1px solid #aaa}.mw-parser-output .div-col dl,.mw-parser-output .div-col ol,.mw-parser-output .div-col ul{margin-top:0}.mw-parser-output .div-col li,.mw-parser-output .div-col dd{page-break-inside:avoid;break-inside:avoid-column}
/* end https://en.wikipedia.org/ */
</style><div class="div-col" style="column-width: 20em;">
<ul><li><a href="Compile_and_go_system" title="Compile and go system">Compile and go system</a></li>
<li><a href="DLL_Hell" class="mw-redirect" title="DLL Hell">DLL Hell</a></li>
<li><a href="Direct_binding" title="Direct binding">Direct binding</a></li>
<li><a href="Dynamic_binding_(computing)" class="mw-redirect" title="Dynamic binding (computing)">Dynamic binding (computing)</a></li>
<li><a href="Dynamic_dispatch" title="Dynamic dispatch">Dynamic dispatch</a></li>
<li><a href="Dynamic_library" title="Dynamic library">Dynamic library</a></li>
<li><a href="Dynamic_linker" title="Dynamic linker">Dynamic linker</a></li>
<li><a href="Dynamic-link_library" title="Dynamic-link library">Dynamic-link library</a></li>
<li><a href="FlexOS" title="FlexOS">FlexOS</a></li>
<li><a href="GNU_linker" class="mw-redirect" title="GNU linker">GNU linker</a></li>
<li><a href="Gold_(linker)" title="Gold (linker)">gold (linker)</a></li>
<li><a href="Lazy_loading" title="Lazy loading">Lazy loading</a></li>
<li><a href="Library_(computing)" title="Library (computing)">Library (computing)</a></li>
<li><a href="Linker_(computing)" title="Linker (computing)">Linker (computing)</a></li>
<li><a href="Loader_(computing)" title="Loader (computing)">Loader (computing)</a></li>
<li><a href="Name_decoration" class="mw-redirect" title="Name decoration">Name decoration</a></li>
<li><a href="Prebinding" class="mw-redirect" title="Prebinding">Prebinding</a></li>
<li><a href="Prelinking" class="mw-redirect" title="Prelinking">Prelinking</a></li>
<li><a href="Relocation_(computer_science)" class="mw-redirect" title="Relocation (computer science)">Relocation (computer science)</a></li>
<li><a href="Relocation_table" class="mw-redirect" title="Relocation table">Relocation table</a></li>
<li><a href="Resident_System_Extension" class="mw-redirect" title="Resident System Extension">Resident System Extension</a> (RSX)</li>
<li><a href="Static_library" title="Static library">Static library</a></li>
<li><a href="Terminate-and-stay-resident_program" title="Terminate-and-stay-resident program">Terminate-and-stay-resident program</a> (TSR)</li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-autobook-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-autobook_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-autobook_1-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://sourceware.org/autobook/autobook/autobook_158.html">Autoconf, Automake, and Libtool: Dynamic Loading</a></span>
</li>
<li id="cite_note-Elf_Dynamic_Loading-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-Elf_Dynamic_Loading_2-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110311170401/http://linux4u.jinr.ru/usoft/WWW/www_debian.org/Documentation/elf/node7.html">"Linux4U: ELF Dynamic Loading"</a>. Archived from <a rel="nofollow" class="external text" href="http://linux4u.jinr.ru/usoft/WWW/www_debian.org/Documentation/elf/node7.html">the original</a> on 2011-03-11<span class="reference-accessdate">. Retrieved <span class="nowrap">2007-12-31</span></span>.</cite></span>
</li>
<li id="cite_note-CICS-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-CICS_3-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://publib.boulder.ibm.com/infocenter/cicsts/v3r1/index.jsp?topic=/com.ibm.cics.ts31.doc/dfhp3/dfhp3oq.htm">"Using the CICS-supplied procedures to install application programs"</a>.</cite></span>
</li>
<li id="cite_note-CEMT-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-CEMT_4-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www-01.ibm.com/support/docview.wss?uid=swg21031546">"IBM CEMT NEWCOPY or PHASEIN request fails with NOT FOR HOLD PROG - United States"</a>. 2013-03-15.</cite></span>
</li>
<li id="cite_note-spe-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-spe_5-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHoOlsson1991" class="citation journal cs1">Ho, W. Wilson; Olsson, Ronald A. (1991). "An approach to genuine dynamic linking". <i>Software: Practice and Experience</i>. <b>21</b> (4): <span class="nowrap">375–</span>390. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.933">10.1.1.37.933</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1002%2Fspe.4380210404">10.1002/spe.4380210404</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:9422227">9422227</a>.</cite></span>
</li>
<li id="cite_note-apache-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-apache_6-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110422182003/http://httpd.apache.org/docs/1.3/dso.html">"Apache 1.3 Dynamic Shared Object (DSO) Support"</a>. Archived from <a rel="nofollow" class="external text" href="https://httpd.apache.org/docs/1.3/dso.html">the original</a> on 2011-04-22<span class="reference-accessdate">. Retrieved <span class="nowrap">2007-12-31</span></span>.</cite></span>
</li>
<li id="cite_note-gcc-strict-aliasing-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-gcc-strict-aliasing_7-0">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Optimize-Options.html#index-fstrict_002daliasing-721">GCC 4.3.2 Optimize Options: -fstrict-aliasing</a></span>
</li>
<li id="cite_note-POSIX_dlopen-8"><span class="mw-cite-backlink">^ <a href="#cite_ref-POSIX_dlopen_8-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-POSIX_dlopen_8-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html">POSIX documentation on <code>dlopen()</code></a> (issues 6 and 7).</span>
</li>
<li id="cite_note-Cat-V-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-Cat-V_9-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://harmful.cat-v.org/software/dynamic-linking/">"Dynamic Linking"</a>. <i>cat-v.org</i>. 9front<span class="reference-accessdate">. Retrieved <span class="nowrap">2014-12-22</span></span>.</cite></span>
</li>
<li id="cite_note-Golang-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-Golang_10-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://golang.org/doc/faq#Why_is_my_trivial_program_such_a_large_binary">"Go FAQ"</a>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li><cite id="CITEREFSilberschatzGalvinGagne2005" class="citation book cs1">Silberschatz, Abraham; Galvin, Peter Baer; Gagne, Greg (2005). "Chapter 8.1.4 "Dynamic Loading" and Chapter 8.1.5 "Dynamic Linking and shared libraries"". <i>Operating System Concepts</i>. <a href="J._Wiley_%26_Sons" class="mw-redirect" title="J. Wiley & Sons">J. Wiley & Sons</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-471-69466-3</bdi>.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li>General Links
<ul><li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110311170401/http://linux4u.jinr.ru/usoft/WWW/www_debian.org/Documentation/elf/node7.html">Dynamic Loading</a> on Linux4U</li>
<li><a rel="nofollow" class="external text" href="https://httpd.apache.org/docs/current/dso.html">Dynamic Shared Object (DSO) Support</a> by <a href="Apache_HTTP_Server" title="Apache HTTP Server">Apache</a></li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080609064104/http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=153">C++ Dynamic Linking By Example</a></li>
<li><a rel="nofollow" class="external text" href="https://github.com/danfuzz/dl-example">Dynamic Library Loading Example</a> (complete but concise working example)</li>
<li><a rel="nofollow" class="external text" href="https://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/Conceptual/DynamicLibraries/000-Introduction/Introduction.html#//apple_ref/doc/uid/TP40001908-SW1">Dynamic Library Programming Topics from Apple Developer Connection (targeted to macOS)</a></li></ul></li>
<li>C/C++ Unix API:
<ul><li><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/009695399/functions/dlopen.html">dlopen</a></li>
<li><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html">dlsym</a></li>
<li><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/009695399/functions/dlclose.html">dlclose</a></li></ul></li>
<li>C/C++ Windows API:
<ul><li><a rel="nofollow" class="external text" href="http://msdn2.microsoft.com/en-us/library/ms684175.aspx">LoadLibrary</a></li>
<li><a rel="nofollow" class="external text" href="http://msdn2.microsoft.com/en-us/library/ms683212(VS.85).aspx">GetProcAddress</a></li>
<li><a rel="nofollow" class="external text" href="http://msdn2.microsoft.com/en-us/library/ms683152(VS.85).aspx">FreeLibrary</a></li>
<li><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/151kt790.aspx">Delay-Loaded DLLs</a></li></ul></li>
<li>Java API:
<ul><li><a rel="nofollow" class="external text" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html">ClassLoader</a></li>
<li><a rel="nofollow" class="external text" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a></li></ul></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-12-22" href="https://en.wikipedia.org/wiki/?title=Dynamic_loading&oldid=1264655829">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>